package com.yxuan.springboot.service.impl;

import com.yxuan.springboot.mapper.JobInformationMapper;
import com.yxuan.springboot.model.JobBaseInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yxuan.springboot.model.JobInformation;
import com.yxuan.springboot.service.JobInformationService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author zchao
 *    JobInformation业务层实现类
 * @date 2023-06-05 13:37:33
 */
@Service
@Transactional
public class JobInformationServiceImpl extends BaseServiceImpl<JobInformation> implements JobInformationService {

    @Autowired
    private JobInformationMapper jobInformationMapper;

    @Override
    public ArrayList findAllJob() throws Exception {
        List<JobInformation> jobInformationList = jobInformationMapper.getTypeByGroup();
        ArrayList mainArrayList = new ArrayList();
        for (JobInformation jobInformation: jobInformationList){
            Map<String,Object> mapItem = new HashMap<>();
            ArrayList arrayList = new ArrayList();
            JobInformation jobInformation1 = new JobInformation();
            jobInformation1.setWorkType(jobInformation.getWorkType());
            List<JobBaseInformation> jobInformationList2 = jobInformationMapper.getParamByWorkType(jobInformation.getWorkType());
            arrayList.addAll(jobInformationList2);
            mapItem.put("list",arrayList);
            mapItem.put("typeName",jobInformation.getWorkType());
            mainArrayList.add(mapItem);
        }
        return mainArrayList;
    }
}
